package com.fancy.recommendation.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fancy.recommendation.entity.HotRanking;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;

/**
 * 热门榜单Mapper
 *
 * @author fancy
 */
@Mapper
public interface HotRankingMapper extends BaseMapper<HotRanking> {

    /**
     * 获取榜单数据
     */
    List<HotRanking> getRankingData(@Param("rankingType") String rankingType,
                                  @Param("periodType") String periodType,
                                  @Param("periodDate") LocalDate periodDate,
                                  @Param("limit") Integer limit);

    /**
     * 获取榜单历史
     */
    List<HotRanking> getRankingHistory(@Param("rankingType") String rankingType,
                                     @Param("periodType") String periodType,
                                     @Param("startDate") LocalDate startDate,
                                     @Param("endDate") LocalDate endDate);

    /**
     * 批量插入榜单数据
     */
    int batchInsertRanking(@Param("rankings") List<HotRanking> rankings);

    /**
     * 清理历史榜单数据
     */
    int deleteHistoryRanking(@Param("beforeDate") LocalDate beforeDate);

    /**
     * 获取当前最新榜单
     */
    List<HotRanking> getLatestRanking(@Param("rankingType") String rankingType,
                                    @Param("periodType") String periodType,
                                    @Param("limit") Integer limit);

    /**
     * 获取排行榜类型列表
     */
    List<Map<String, Object>> getRankingTypes();

    /**
     * 删除指定榜单数据
     */
    int deleteRankingByTypeAndDate(@Param("rankingType") String rankingType,
                                 @Param("periodType") String periodType,
                                 @Param("periodDate") LocalDate periodDate);
}
